	
	boolean someoneWon = false;
	int winner = -1;
	boolean thirtyCountries = false;
		
	public void checkForWin()
	{
		
		for(int i = 0; i < rules[RULES.MATCH_PLAYERS]; i++)
		{
			if(tegPlayers[i].objectiveId < RULES.OBJECTIVES.length - 6)
			{
				someoneWon = true;
				winner = i;
				
				#ifdef DEBUG_WIN_CONDITIONS
				System.out.println("");
				System.out.println("=====================================================");
				System.out.println("Checking Win condition of Player " + i + ", " + tegPlayers[i].name + ":");
				System.out.println("=====================================================");
				#endif
				
				for(int j = 0; j < RULES.OBJECTIVES[tegPlayers[i].objectiveId].length; j++)
				{
					#ifdef DEBUG_WIN_CONDITIONS
					System.out.println("Condition " + j + ": ");
					System.out.println("      Target: " + RULES.OBJECTIVES[tegPlayers[i].objectiveId][j]);
					System.out.println("      Current: " + countriesInContinent(i, j));
					System.out.println("      Result: " + (countriesInContinent(i, j) >= RULES.OBJECTIVES[tegPlayers[i].objectiveId][j]));
					#endif
					if(!(countriesInContinent(i, j) >= RULES.OBJECTIVES[tegPlayers[i].objectiveId][j]))
					{
						someoneWon = false;
						winner = -1;
					}
				}
				
				#ifdef DEBUG_WIN_CONDITIONS
				System.out.println("Has thirty countries: ");
				#endif
				if(playerCountries(i) >= 30)
				{
					#ifdef DEBUG_WIN_CONDITIONS
					System.out.println("    Yes");
					#endif
					someoneWon = true;
					thirtyCountries = true;
					winner = i;
				}
				#ifdef DEBUG_WIN_CONDITIONS
				else
				{
					System.out.println("    No");
				}
				System.out.println("=====================================================");
				#endif
				
				if(someoneWon)
				{
					#ifdef DEBUG_WIN_CONDITIONS
					System.out.println("VICTORY!");
					#endif
					SetIngameState(STATES.INGAME_MATCH_END);
					break;
				}
			}
		}
	}
	
	public int countriesInContinent(int player, int continent)
	{
		int countriesThere = 0;
	
		for(int i = COUNTRY_INFO.FIRST_COUNTRY_OF_CONTINENT[continent]; i <= COUNTRY_INFO.LAST_COUNTRY_OF_CONTINENT[continent]; i++)
		{
			if(tegCountries[i].owner == player)
			{
				countriesThere++;
			}
		}
		
		return countriesThere;
	}
	
	public void UpdateWinner()
	{
		int width = ((cGame_g.getStringWidth(tegPlayers[winner].name) > INGAME.OBJECTIVE_W)?cGame_g.getStringWidth(tegPlayers[winner].name) : INGAME.OBJECTIVE_W) + cGame_g.getFontPixelSize() * 4;
		int height = cGame_g.getFontHeight() * 2 + INGAME.OBJECTIVE_H + cGame_g.getFontPixelSize() * 6;
		int x = SCREEN_WIDTH / 2 - width / 2;
		int y = SCREEN_HEIGHT / 2 - height / 2;
		
		int staticPixelSize = cGame_g.getFontPixelSize();
		int staticFontHeight = cGame_g.getFontHeight();
		
		drawSoftKeys(SOFTKEYS.STR_CONTINUE, SOFTKEYS.STR_NONE);
		
		#ifdef USE_DRAWRGB
		cGame_g.setColor(tegPlayers[winner].color);
		cGame_g.drawAlphaRect(x, y, width, height, MENUS.MAIN_MENU_ALPHA_LEVEL);
		#else
		cGame_g.setColor(tegPlayers[winner].color);
		cGame_g.fillRect(x, y, width, height);
		#endif
		cGame_g.setColor(MENUS.MAIN_MENU_FOREGROUND_COLOR);
		cGame_g.drawRect(x, y, width, height);
		
		cGame_g.setFontColor(MENUS.MAIN_MENU_HIGHLIGHT_COLOR);
		cGame_g.drawString(TEXT.WINNER, SCREEN_WIDTH / 2, y + cGame_g.getFontPixelSize() * 2, DSmallFont.TOP | DSmallFont.HCENTER);
		cGame_g.setFontColor(tegPlayers[winner].color + 0x444444);
		cGame_g.drawString(tegPlayers[winner].name, SCREEN_WIDTH / 2, y + cGame_g.getFontPixelSize() * 3 + cGame_g.getFontHeight(), DSmallFont.TOP | DSmallFont.HCENTER);
		
		cGame_g.setColor(CARDS.CARD_COLOR);
		cGame_g.fillRect(INGAME.OBJECTIVE_X, y + cGame_g.getFontPixelSize() * 4 + cGame_g.getFontHeight() * 2, INGAME.OBJECTIVE_W, INGAME.OBJECTIVE_H);
		cGame_g.setFont(DGraph.FONT_SMALL);
		cGame_g.setFontColor(CARDS.CARD_TEXT_COLOR);
		cGame_g.drawString(TEXT.OBJECTIVES[tegPlayers[winner].objectiveId], SCREEN_WIDTH / 2, y + staticPixelSize * 4 + staticFontHeight * 3, INGAME.OBJECTIVE_W - cGame_g.getFontWidth() * 2, DSmallFont.HCENTER | DSmallFont.TOP);
		#ifndef REMOVE_IMAGES
		cGame_g.drawRegion(cardsImg, SPRITES.CARD_MODULE_X[SPRITES.CARD_THING], SPRITES.CARD_MODULE_Y[SPRITES.CARD_THING], SPRITES.CARD_MODULE_W[SPRITES.CARD_THING], SPRITES.CARD_MODULE_H[SPRITES.CARD_THING], 0, INGAME.OBJECTIVE_X + INGAME.OBJECTIVE_W - SPRITES.CARD_MODULE_W[SPRITES.CARD_THING] - SPRITES.CARD_MODULE_W[SPRITES.CARD_THING] / 3, y + staticPixelSize * 4 + cGame_g.getFontHeight() * 2 + INGAME.OBJECTIVE_H - SPRITES.CARD_MODULE_H[SPRITES.CARD_THING] - SPRITES.CARD_MODULE_H[SPRITES.CARD_THING] / 5, 0);
		#endif
		cGame_g.setFont(DGraph.FONT_BIG);
		
		playSound(SOUND.SND_WIN, 1, false);
		
		if(isKeyPressed(KEYS.KEY_LSK))
		{
			// FIX OF HIGH BUG (FIX DE ALTO BUG!!!): CONSTANTS CHANGES ITS VALUES!!! WTF!!!
			for(int i = 0; i < COUNTRY_INFO.TOTAL_COUNTRIES; i++)
			{
				tegCountries[i].collisionRect[cCountry.RECT_X] -= INGAME.VIEWPORT_X;
				tegCountries[i].collisionRect[cCountry.RECT_Y] -= INGAME.VIEWPORT_Y;
			}
			// END FIX
			someoneWon = false;
			thirtyCountries = false;
			winner = -1;
			stopSound();
			SetIngameState(STATES.INGAME_INIT);
			SetState(STATES.MAIN_MENU);
			clearKeys();
		}
	}